import { useMemberStore } from '@/stores'

export function usePermission() {
  const userStore = useMemberStore()
  
  const checkPermission = (requiredPermissions: string[]) => {
    try {
      const userPermissions = userStore.wxps ? userStore.wxps.split(',') : [];
      
      if (requiredPermissions && Array.isArray(requiredPermissions)) {
        return requiredPermissions.some((permission: string) => 
          userPermissions.includes(permission)
        );
      }
      return false;
    } catch (error) {
      console.error('权限检查出错:', error);
      return false;
    }
  }
  
  return {
    checkPermission
  }
} 